import { configureStore } from "@reduxjs/toolkit";
import { usersApi } from "../api/users";
import { setupListeners } from "@reduxjs/toolkit/query";
import { postsApi } from "../api/posts";
import { todosApi } from "../api/todos";
import { albumApi } from "../api/album";

export const store = configureStore({
  reducer: {
    [usersApi.reducerPath]: usersApi.reducer,
    [postsApi.reducerPath]: postsApi.reducer,
    [todosApi.reducerPath]: todosApi.reducer,
    [albumApi.reducerPath]: albumApi.reducer,
  },
  middleware: (getDefaultMiddleware) =>
    getDefaultMiddleware().concat(
      usersApi.middleware,
      postsApi.middleware,
      todosApi.middleware,
      albumApi.middleware
    ),
});

setupListeners(store.dispatch);
